package fxlauncher;

import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.control.ProgressBar;
import javafx.scene.image.ImageView;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class CustomPicLauncherUI implements UIProvider {
    private ProgressBar progressBar;

    public CustomPicLauncherUI() {
    }

    public Parent createLoader() {
        VBox root = new VBox();
        ImageView imageView = new ImageView(this.getClass().getResource(this.getImagePath()).toExternalForm());
        this.progressBar = new ProgressBar();
        this.progressBar.setPrefWidth(imageView.getImage().getWidth());
        root.getChildren().addAll(new Node[]{imageView, this.progressBar});
        return root;
    }

    public Parent createUpdater(FXManifest manifest) {
        return null;
    }

    public void updateProgress(double progress) {
        this.progressBar.setProgress(progress);
    }

    public void init(Stage stage) {
    }

    private String getImagePath() {
        return "/splash.png";
    }

}
